package com.boot.dao;

import com.boot.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserDao {


    @Select("select * from user where username=#{username}")
    @Result(column = "company_id",property = "companyId")
    @Result(column = "department_id",property = "departmentId")
    public User getUser(String username);

    @Select("select * from user")
    @Result(column = "company_id",property = "companyId")
    @Result(column = "department_id",property = "departmentId")
    public List<User> getUsers();


    @Insert("INSERT INTO user(name, username, phone, addr, email, pwd, role, department_id, company_id, del) \n" +
            "VALUES (#{name}, #{username}, #{phone}, #{addr}, #{email}, #{pwd},#{role},#{departmentId},#{companyId},#{del});")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    public void addUser(User user);

}
